package com.company.cloud.club.modules.db.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.company.cloud.club.modules.db.domain.ClubInfo;
import com.company.cloud.club.modules.db.domain.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ClubInfoMapper extends BaseMapper<ClubInfo> {

    @Select("SELECT * FROM club_info WHERE deleted = 0 AND sug = 1 ORDER by sort desc")
    List<ClubInfo> querySug();

    @Select("SELECT * FROM club_info WHERE deleted = 0 ORDER by sort desc")
    List<ClubInfo> selectAll();

    @Update("UPDATE club_info SET deleted = 1 WHERE id = #{id, jdbcType=VARCHAR}")
    boolean removeClub(@Param("id") String id);

    @Select("SELECT * FROM club_info " +
            "WHERE deleted = 0 AND name LIKE CONCAT('%', #{condition,jdbcType=VARCHAR}, '%') " +
            "OR intro LIKE CONCAT('%', #{condition,jdbcType=VARCHAR}, '%') " +
            "ORDER BY sort DESC;")
    List<ClubInfo> selectClubByCondition(@Param("condition") String condition);

}